LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads State StateT

Contents

record StateT <S, M, A> (Func<S, K<M, (A Value, S State)>> runState) Source #

where M : Monad<M>, SemiAlternative<M>

StateT monad transformer, which adds a modifiable state to a given monad.

Parameters

type S

State type

type M

Given monad trait

type A

Bound value type

param runState

Transducer that represents the transformer operation

Properties

property StateT<S, M, S> Get Source #

Extracts the state value and returns it as the bound value

Parameters

returns

StateT

Methods

method StateT<S, M, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

StateT

method StateT<S, M, Unit> Modify (Func<S, S> f) Source #

Extracts the state value, maps it, and then puts it back into the monadic state.

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, Unit> ModifyM (Func<S, K<M, S>> f) Source #

Extracts the state value, maps it, and then puts it back into the monadic state.

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, Unit> Put (S value) Source #

Writes the value into the monadic state

Parameters

returns

StateT

method StateT<S, M, A> State (A value, S state) Source #

Writes a value and state into the monad

Parameters

returns

StateT

method StateT<S, M, A> State ((A value, S state) ma) Source #

Writes a value and state into the monad

Parameters

returns

StateT

method StateT<S, M, A> Gets (Func<S, A> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, A> GetsM (Func<S, K<M, A>> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

StateT

method StateT<S, M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

StateT

method StateT<S, M, A> Lift (Func<A> f) Source #

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

StateT

method StateT<S, M, A> LiftIO (IO<A> ma) Source #

Lifts a an IO monad into the monad

NOTE: If the IO monad isn't the innermost monad of the transformer stack then this will throw an exception.

Parameters

param ma

IO monad to lift

returns

StateT

method StateT<S, M1, B> MapT <M1, B> (Func<K<M, (A Value, S State)>, K<M1, (B Value, S State)>> f) Source #

where M1 : Monad<M1>, SemiAlternative<M1>

Maps the given monad

Parameters

type M1

Trait of the monad to map to

param f

Mapping function

returns

StateT

method StateT<S, M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

returns

StateT

method StateT<S, M, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, K<StateT<S, M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, StateT<S, M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, Gets<S, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, Unit> Bind (Func<A, Put<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, Unit> Bind (Func<A, Modify<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, K<StateT<S, M>, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, StateT<S, M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <C> (Func<A, Put<S>> bind, Func<A, Unit, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, Gets<S, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <C> (Func<A, Modify<S>> bind, Func<A, Unit, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method K<M, (A Value, S State)> Run (S state) Source #

Run the state monad

Parameters

param state

Initial state

returns

Bound monad

Operators

operator | (StateT<S, M, A> ma, StateT<S, M, A> mb) Source #

operator | (StateT<S, M, A> ma, Pure<A> mb) Source #

operator | (Pure<A> ma, StateT<S, M, A>mb) Source #

operator | (IO<A> ma, StateT<S, M, A> mb) Source #

class StateTExtensions Source #

State monad extensions

Methods

method StateT<Env, M, A> As <Env, M, A> (this K<StateT<Env, M>, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<Env, M, A> Flatten <Env, M, A> (this StateT<Env, M, StateT<Env, M, A>> mma) Source #

where M : Monad<M>, SemiAlternative<M>

Monadic join

method StateT<Env, M, C> SelectMany <Env, M, A, B, C> ( this K<M, A> ma, Func<A, K<StateT<Env, M>, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>, SemiAlternative<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method StateT<Env, M, C> SelectMany <Env, M, A, B, C> ( this K<M, A> ma, Func<A, StateT<Env, M, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>, SemiAlternative<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

class StateT <S> Source #

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method StateT<S, M, A> lift <M, A> (K<M, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

class StateT <S, M> Source #

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method StateT<S, M, A> Pure <A> (A value) Source #

method StateT<S, M, A> liftIO <A> (IO<A> effect) Source #

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

StateT

class StateT Source #

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method StateT<S, M, B> bind <S, M, A, B> (StateT<S, M, A> ma, Func<A, StateT<S, M, B>> f) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, B> map <S, M, A, B> (Func<A, B> f, StateT<S, M, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, A> Pure <S, M, A> (A value) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, B> apply <S, M, A, B> (StateT<S, M, Func<A, B>> mf, StateT<S, M, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, B> action <S, M, A, B> (StateT<S, M, A> ma, StateT<S, M, B> mb) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, A> lift <S, M, A> (K<M, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, A> liftIO <S, M, A> (IO<A> effect) Source #

where M : Monad<M>, SemiAlternative<M>

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

StateT

method StateT<S, M, S> get <M, S> () Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, A> gets <M, S, A> (Func<S, A> f) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, A> getsM <M, S, A> (Func<S, K<M, A>> f) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, Unit> put <M, S> (S state) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, Unit> modify <M, S> (Func<S, S> f) Source #

where M : Monad<M>, SemiAlternative<M>

method StateT<S, M, Unit> modifyM <M, S> (Func<S, K<M, S>> f) Source #

where M : Monad<M>, SemiAlternative<M>

class StateT <S, M> Source #

where M : Monad<M>, SemiAlternative<M>

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait